package com.larry.bp.controller;

import com.larry.bp.model.User;
import com.larry.bp.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/show")
    @ResponseBody
    public void show() {

        List<User> userList=userService.findByUserName();

        for (User user:userList){
            System.out.println(user.getName());
        }

    }

    @RequestMapping("/open")
    public String open() {
       return "user/index";
    }
    @RequestMapping("/error")
    public String error() {
        return "error";
    }
}
